<?php

/**
 * 首页控制器
 * @author:Cloud
 * @copyright:TcitCMS
 * @since:2014-05-12
 */

namespace Home\Controller;

class MainController extends CommonController
{

    function _initialize()
    {
        parent::_initialize();
    }

    function index()
    {
        $model = new \Common\Model\NewsModel();

        $processData = $model->find(2);
        $processData['content'] = $this->handle($processData['content'], 150);
        $this->assign('processData', $processData);

        $aboutData = $model->find(1);
        $aboutData['content'] = $this->handle($aboutData['content'], 200);
        $this->assign('aboutData', $aboutData);

        $newsTData = $model->where('`lm_id`=2 and `category`=1 and `deleted`=0 and `is_tj`=1 and `smallpic`<>""')->limit(1)->order('created desc')->select();
        $newsTData[0]['content'] = $this->handle($newsTData[0]['content'], 70);
        $this->assign('newsTData', $newsTData[0]);

        $newsData = $model->where('`lm_id`=2 and `category`=1 and `deleted`=0')->limit(4)->order('created desc')->select();
        foreach ($newsData as $k => $v) {
            $newsData[$k]['title'] = $this->handle($v['title'], 23);
        }
        $this->assign('newsData', $newsData);

        $news1Data = $model->where('`lm_id`=2 and `category`=3 and `deleted`=0')->limit(6)->order('created desc')->select();
        foreach ($news1Data as $k => $v) {
            $news1Data[$k]['title'] = $this->handle($v['title'], 23);
        }
        $this->assign('news1Data', $news1Data);

        $news2Data = $model->where('`lm_id`=2 and `category`=6 and `deleted`=0')->limit(6)->order('created desc')->select();
        foreach ($news2Data as $k => $v) {
            $news2Data[$k]['title'] = $this->handle($v['title'], 23);
        }
        $this->assign('news2Data', $news2Data);

        $news3Data = $model->where('`lm_id`=2 and `category`=2 and `deleted`=0')->limit(5)->order('created desc')->select();
        foreach ($news3Data as $k => $v) {
            $news3Data[$k]['title'] = $this->handle($v['title'], 18);
        }
        $this->assign('news3Data', $news3Data);

        $teamData = $model->where('`lm_id`=4 and `deleted`=0')->limit(15)->order('created desc')->select();
        $this->assign('teamData', $teamData);

        $zhizData = $model->where('`lm_id`=5 and `deleted`=0')->order('created desc')->select();
        $this->assign('zhizData', $zhizData);

        $this->assign('web_title', '首页');
        $this->display();
    }

}

?>